package day44;

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            Stack<Character> stack1 = new Stack<>();
            Stack<Character> stack2 = new Stack<>();
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z' || str.charAt(i) >= 'A' &&
                        str.charAt(i) <= 'Z') {
                    stack1.push(str.charAt(i));
                    continue;
                }
                if (!stack1.empty() && stack2.empty()) {
                    int len = stack1.size();
                    for (int j = 0; j < len; j++) {
                        stack2.push(stack1.pop());
                    }
                } else if(!stack1.empty() && !stack2.empty()) {
                    stack2.push(' ');
                    int len = stack1.size();
                    for (int j = 0; j < len; j++) {
                        stack2.push(stack1.pop());
                    }
                }
            }
            while(!stack1.empty()) {
                stack2.push(' ');
                int len = stack1.size();
                for (int j = 0; j < len; j++) {
                    stack2.push(stack1.pop());
                }
            }
            int len1 = stack2.size();
            StringBuilder str2 = new StringBuilder();
            for(int i = 0; i < len1; i++) {
                str2.append(stack2.pop());
            }
            System.out.println(str2.toString());
        }
    }
}